package com.tepth.bustun;

import android.content.Intent;
import android.os.Bundle;

import com.tencent.bugly.beta.Beta;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import st.business.tepth.BusTunActivity;
import st.business.tepth.business.event.CheckVersionEvent;

public class MainActivity extends BusTunActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (savedInstanceState != null) {
            Intent intent = new Intent(this, MainActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                    | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            startActivity(intent);
        } else {
            EventBus.getDefault().register(this);
        }
    }

    @Subscribe
    public void onCheckVersionEvent(CheckVersionEvent event) {
        Beta.checkUpgrade(true, false);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}
